package cn.jkgly.test.Controller;//package cn.jkgly.test.Controller;
//
//import org.jeecgframework.core.common.controller.BaseController;
//import org.jeecgframework.web.system.service.SystemService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Controller;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.servlet.ModelAndView;
//import webd.service.SaoMaService;
//import weixin.buss.ksptopenid.entity.WeixinKsptOpenidEntity;
//import weixin.buss.ksptopenid.service.WeixinKsptOpenidServiceI;
//import weixin.guanjia.account.service.WeixinAccountServiceI;
//import weixin.guanjia.core.util.WeixinUtil;
//import weixin.web.entity.WeixinUser;
//import weixin.web.service.IdAuthService;
//
//import javax.servlet.http.HttpServletRequest;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
//@Controller
//@RequestMapping("/saoMaController")
//public class SaoMaController  extends BaseController {
//    @Autowired
//    private IdAuthService idAuthService;
//    private SaoMaService saoMaService;
//    @Autowired
//    private SystemService systemService;
//    @Autowired
//    private WeixinKsptOpenidServiceI weixinKsptOpenidService;
//    public void checkSessoin(HttpServletRequest request, String code, String state){
//        String url = WeixinUtil.oauth2_access_token_url.replace("CODE",
//                code);
//        WeixinUser weixinUser = weixinAccountService.getWxuserinfoByCode(systemService,url,state);
//        request.getSession().setAttribute("weixinUser", weixinUser);
//    }
//    @Autowired
//    private WeixinAccountServiceI weixinAccountService;
//
//    @RequestMapping(params = "saoMa")
//    public ModelAndView saoMa(HttpServletRequest request, String code, String state) {
//        String uuid =request.getParameter("uuid");
//        String returnStr = "web/qr/queren";
//        checkSessoin(request,code,state);
//        WeixinUser weixinUser = (WeixinUser)request.getSession().getAttribute("weixinUser");
//        String openid = weixinUser.getOpenid();
//        request.setAttribute("openid", openid);
//        request.setAttribute("uuid", uuid);
//        Map<String, Object> map = new HashMap<String, Object>();
//        /*Bind bind = idAuthService.findUniqueByProperty(Bind.class, "openId", openid);
//        if(null == bind){
//            returnStr = "weixin/idauth/binding";
//        }else {
//            weixinUser.setName(bind.getName());
//            weixinUser.setIdcard(bind.getIdCard());
//        }*/
//        //List<String> openids =saoMaService.findListbySql("select openid from WEIXIN_OPENID");
//        List<WeixinKsptOpenidEntity> weixinKsptOpenids =weixinKsptOpenidService.getList(WeixinKsptOpenidEntity.class);
//        String flag ="N";
//        for(int i=0;i<weixinKsptOpenids.size();i++){
//            if(openid.equals(weixinKsptOpenids.get(i).getOpenid())){
//                flag="Y";
//            }
//        }
//        request.setAttribute("flag", flag);
//        request.getSession().setAttribute("uuid", uuid);
//        map.put("weixinUser", weixinUser);
//        return new ModelAndView(returnStr,map);
//    }
//
//
//
//}
